<template>
	<view class="open-page">
		<view class="open-header">
			<image src="/static/images/open-account.png" />
		</view>
		<!-- 国元期货 -->
		<view class="open_text">
			<view class="open_left">
				<u-avatar :src="img" size="50"></u-avatar>
				<view style="padding: 10px;">{{name}}</view>
			</view>
			<view class="open_right" @click="goopenFn">其他期货公司 ></view>
		</view>
		<view class="open-body">
			<view class="btn open-btn" @click="runKaihuFun">快速在线开户</view>
			<view class="btn help-btn border" @click="runHelpFun">开户帮助</view>
		</view>
	</view>
</template>

<script>
	// const dcRichAlert = uni.requireNativePlugin('Trader')
	// const SjkfAlert = uni.requireNativePlugin('Sjkf')
	import {
		mapMutations,
		mapGetters
	} from 'vuex'
	import {
		openAccount
	} from '@/api/trader.js'
	import {
		toAccountHelpPage
	} from '@/utils/PageRouter.js'
	const SjkfAlert = uni.requireNativePlugin('Sjkf')
	export default {
		computed: {
			...mapGetters([
				'alldata'
			])
		},
		data() {
			return {
				dataList: [],
				brokerId: '',
				cfmmcUrl: '',
				channel: '',
				name: '',
				img: '',
				list: []
			};
		},
		created() {
			this.accountCloud()
		},
		onLoad() {

		},
		onShow() {

		},
		mounted() {
			this.test()
		},
		methods: {
			frequency() {
				let user_id = uni.getStorageSync('user_id')
				uni.request({
					url: 'https://wechat.sou-liang.com/api/v1/frequency',
					method: 'POST',
					data: {
						type: 1,
						id: user_id
					},
					success: (res) => {
						let data = res.data.data
					}
				});
			},
			accountCloud() {
				uni.request({
					url: 'https://wechat.sou-liang.com/api/v1/defaultKaiHuYun',
					data: {},
					success: (res) => {
						let data = res.data.data
						this.name = data.name
						this.img = data.img
						//this.dataList = res.data.data
						uni.setStorageSync('brokerId', data.brokerId)
						uni.setStorageSync('cfmmcUrl', data.cfmmcUrl)
						uni.setStorageSync('channel', data.channel)
						// #ifdef APP-PLUS
						// #endif
					}
				});
			},
			runKaihuFun() {
				this.brokerId = uni.getStorageSync('brokerId')
				this.cfmmcUrl = uni.getStorageSync('cfmmcUrl')
				this.channel = uni.getStorageSync('channel')
				uni.showToast({
					title: '正在启动开户云',
					icon: 'none'
				})
				this.frequency()
				openAccount()
				// if (plus.os.name == "Android") {
				// 	// var n = plus.android.importClass("com.cfmmc.app.sjkh.MainActivity")
				// 	// var n = plus.android.importClass("com.CfmmcMainActivity.app.sjkh.MainActivity")
				// 	var n = plus.android.importClass("com.cfmmc.app.cfmmckh.activity.CfmmcMainActivity")
				// 	var a = plus.android.runtimeMainActivity()
				// 	var i = plus.android.importClass("android.content.Intent")
				// 	var t = new i(a, n.class)
				// 	// t.putExtra("brokerId", "0015")
				// 	// t.putExtra("mobile", "17365538643")
				// 	// t.putExtra("channel", "003")
				s // 	t.putExtra("brokerId", "0182")
				// 	t.putExtra("cfmmcUrl", "https://app5.cfmmc.com")
				// 	t.putExtra("channel", "@1022$H0086")
				// 	// t.putExtra("cfmmcUrl", "https://apptest5bus.cfmmc.com")
				// 	a.startActivity(t)
				// } else {
				// 	var r = plus.ios.invoke("qhyWrapperViewController", "sharedInstance")
				// }
			},
			runHelpFun() {
				toAccountHelpPage()
			},
			goopenFn() {
				uni.redirectTo({
					url: '../futures/futures'
				})
			}
		}
	}
</script>

<style lang="scss" scoped>
	.minImg {
		width: 20px;
		height: 20px;
	}

	.open-page {
		height: 100vh;
		background-color: #fff;

		.open-header {
			width: 750rpx;
			height: 847rpx;
		}

		.open_text {
			display: flex;
			justify-content: space-between;
			align-items: center;
			padding: 10px 30px 0;
			font-weight: bold;

			.open_left {
				display: flex;
				align-items: center;

				.img {
					width: 20px;
					height: 20px;
					margin-right: 10px;
				}

			}

			.open_right {
				color: #777777;
			}
		}

		.open-body {
			padding: 60rpx;

			.btn {
				width: 100%;
				height: 80rpx;
				margin-top: 24rpx;
				text-align: center;
				line-height: 80rpx;
				border-radius: 30rpx;
			}

			.open-btn {
				color: #fff;
				background-image: linear-gradient(to right, #F38200, #EF5904)
			}

			.help-btn {
				color: #F78E28;

				&:after {
					border-color: #F3B669;
					border-radius: 60rpx;
				}
			}
		}
	}
</style>
